<?php $html->css('/events/css/events.css',null,array(),false);?>
<div class="noborder">
	<div class="events view">
		<dl>
		<?php $i = 0; $class = ' class="altrow"';?>
			<div class="fl " style="width: 60%;">
					<center>
						<h3>
						<?php echo $event['Event']['title']; ?>
						</h3>
					</center>
				<table border='0' width='100%'>
					<tr>
						<td width='25%'><?php echo '<b>'.__("Category").': </b>';?>
						</td>
						<td width='75%'>
							<?php echo $html->link($event['EventCategory']['name'], array("plugin"=>"events",'controller' => 'event_categories', 'action' => 'view', $event['EventCategory']['id'])); ?>
						</td>
					</tr>
					<tr>
						<td width='25%'><?php echo '<b>'.__("When").': </b>';?>
						</td>
						<td width='75%'>
							<?php echo substr($event['Event']['event_from'],8,2)."/".substr($event['Event']['event_from'],5,2)."&nbsp;".substr($event['Event']['event_from'],11,5)."&nbsp;-&nbsp;".substr($event['Event']['event_to'],8,2)."/".substr($event['Event']['event_to'],5,2)."&nbsp;".substr($event['Event']['event_to'],11,5);?>
						</td>
					</tr>
					<tr>
						<td width='25%'><?php echo '<b>'.__("Venue").': </b>';?>
						</td>
						<td width='75%'>
							<?php echo $event['Event']['venue']; ?>
						</td>
					</tr>
					<tr>
						<td width='25%'><?php echo '<b>'.__("Cost").': </b>';?>
						</td>
						<td width='75%'>
							<?php
								if(isset($event['Event']['event_cost']) && isset($event['Event']['event_cost']) && ($event['Event']['event_cost']>0 || $event['Event']['event_cost_to']>0)) {
									echo "$".$event['Event']['event_cost']." ".__("to")." $".$event['Event']['event_cost_to'];
								} 
								else{
									echo __("Free");
								}
							?>
						</td>
					</tr>
				</table>
			</div>
			<div class="fl images_section">
				<?php
				$img = $html->image($event['Event']['image'],array('thumb'=>array('crop'=>true,'width'=>200,'height'=>150),'class'=>'thumbnail','alt'=>sprintf(__("%s picture"),$event['Event']['title'])));
				echo $html->link($img, array("plugin"=>"events","controller"=>"event_assets",'action'=>'index','event','eventId'=>$event['Event']['id']),array('escape'=>false));
				?>
				<br />
				<!-- code to show event assets starts here-->
				<?php if(!empty($eventAssets))
				{?>
				<ul>
				<?php
				$imageLimit = 3;
				$i = 0;
				foreach($eventAssets as $eventAsset)
				{
					$eventAsset = $eventAsset['EventAsset'];
					?>
					<?php
					if($i == $imageLimit)
					{
						break;
					}
					?>
					<li style='float: left;'><?php echo $html->link($html->image($eventAsset['file_url'],array('thumb'=>array('crop'=>true,'width'=>60,'height'=>45))),array("controller"=>"event_assets",'action'=>'index','event','eventId'=>$event['Event']['id'],'show'=>$eventAsset['id']),array('escape'=>false));?>
					</li>
					<?php $i++;
				}?>
				</ul>
				<?php }?>
				<div class="clear"></div>
				<?php
				$allowImageLinks = true;
				?>
				<?php if($allowImageLinks){?>
				<?php echo $html->link(__('Upload pic'),array('controller'=>'event_assets','action'=>'add',$event['Event']['id']),array('class'=>'fr'));?>
				<br />
				<?php } ?>
				<?php if(count($eventAssets)){?>
				<?php echo $html->link(__('View All Pics'),array("controller"=>"event_assets",'action'=>'index','event','eventId'=>$event['Event']['id']),array('class'=>'fr'))?>
				<?php } ?>
				<div class="clear"></div>
				<!-- code to show event assets ends here-->
	
			</div>
			<div class="clear"></div>
			<table border='0' width='100%'>
				<tr>
					<td rowspan="2" style="valign: middle;" width='25%'><?php echo '<b>'.__("How").': </b>';?>
					</td>
					<td width='75%'>
						<?php 
						if(substr($event['Event']['event_site'], 0, 7) === "http://" || substr($event['Event']['event_site'], 0, 8) === "https://") { 
							$url = $event['Event']['event_site'];  
						} else { 
							$url = "http://".$event['Event']['event_site'];
						}
						echo $html->link($event['Event']['event_site'],$url);
						?>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php 
						if(substr($event['Event']['ticket_site'], 0) === "http://") {
							$url = $event['Event']['ticket_site'];  
						} else { 
							$url = "http://".$event['Event']['ticket_site'];
						}
						echo $html->link($event['Event']['ticket_site'],$url);
						?>
					</td>
				</tr>
				<tr>
					<td width='25%'><?php echo '<b>'.__("Submitted By").': </b>';?>
					</td>
					<td width='75%'>
						<?php
						if(isset($event['Event']['user_id']))
						{
							if(isset($event['User']))
							{
								echo $html->link($html->image($event['User']['avatar'],array('class'=>"profile_pic",'alt'=>sprintf(__("%s profile"),$event['User']['username']),'thumb'=>array('crop'=>true,'width'=>40,'height'=>40))),$event['User']['profile_url'],array("escape"=>false));
							}
							echo "&nbsp;&nbsp;&nbsp;".$html->link($event['User']['username'], $event['User']['profile_url']);
						}
						else
						{
							echo __("Admin");
						}
						?>
					</td>
				</tr>
				<tr>
					<td width='25%'><?php echo '<b>'.__("What/Why").': </b>';?>
					</td>
					<td width='75%'>
						<?php echo $event['Event']['description']; ?>
					</td>
				</tr>
				<?php if(isset($event['Event']['listing_id']) && !is_null($event['Event']['listing_id']) && $event['Event']['listing_id']!=0) {?>
				<tr>
					<td width='25%'><?php echo '<b>'.__("Business").': </b>';?>
					</td>
					<td width='75%'>
						<?php echo $html->link($listing['Listing']['title'],array('action'=>'view','controller'=>'listings','plugin'=>null,$listing['Listing']['id'])); ?>
						<div class="rating">
						<?php
							$disableEditorReviews = cr('GeneralConfig.disable_editor_reviews');
							$_userReviewCount = '<div style="float:left;margin-left:80px">('.$listing['Listing']['review_count'].')</div>';
							$_userRating = $listing['Listing']['userAvg'];
							$_editorRating = $listing['Listing']['editorialAvg'];
							
							echo $rating->display(array('rating'=>$_userRating,'before_text'=>$_userReviewCount,'tooltip'=>__('User Rating').' '.number_format($_userRating,1),'tooltipClass'=>'user_'.$listing['Listing']['id'].'_'.mt_rand(1,1000)));
							
							$editorRatingHtml = '';
							if($disableEditorReviews != 1)
							{
								echo $rating->display(array('rating'=>$_editorRating,'class'=>'editor_rating_star_value', 'parent_class'=>'editor_rating_star_base', 'tooltip'=>__('Editor Rating').' '.number_format($_editorRating,1),'tooltipClass'=>'editor_'.$listing['Listing']['id'].'_'.mt_rand(1,1000)));
							}
						?>
						</div>
					</td>
				</tr>
				<?php }?>				
				
				<?php
				if(!empty($event['Event']['popularized_date'])):
				?>
				<tr>
					<td width='25%'><?php echo '<b>'.__("Popularized On").': </b>';?>
					</td>
					<td width='75%'>
						<?php echo $event['Event']['popularized_date']; ?>
					</td>
				</tr>
				<?php endif; ?>
				</table>
				<table border='0' width='100%'>
				<tr>
					<td width='25%'>
						<?php echo '<b>'.__("Comments Received").': </b>';?>
						<?php echo $event['Event']['comment_count']; ?>
					</td>
					<td width='25%'>
						<?php echo '<b>'.__("Total Views").': </b>';?>
						<?php echo $event['Event']['views_count']; ?>
					</td>
					<td width='25%'>
						<?php echo '<b>'.__("Attendees").': </b>';?>
						<?php echo $event['Event']['whosin_count']; ?>
					</td>
					<td width='25%'>
						<?php echo '<b>'.__("Considered Cool By").': </b>';?>
						<?php echo $event['Event']['soundscool_count']; ?>
					</td>
				</tr>
				<tr>
					<td colspan=4>
						<table>
							<tr>
								<td>
									<center>
									<?php echo $html->link(__('Edit', true), array('action' => 'edit', $event['Event']['id'])); ?>
									</center>
								</td>
								<td>
									<center>
									<?php echo $html->link(__('Delete', true), array('action' => 'delete', $event['Event']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $event['Event']['id'])); ?>
									</center>
								</td>
							</tr>
						</table>
					</td>
				</tr>			
			</table>
	</div>


	<div id="event_comments" class="related">
		<h4>
		<?php echo __('Related Event Comments');?>
		</h4>
		<?php 
			if(!empty($comments)){
				echo "<table>";
				foreach ($comments as $comment){
					echo "<tr><td rowspan=2 width='10%'>";
					if(isset($comment['User']))
					{
						echo $html->link($html->image($comment['User']['avatar'],array('class'=>"profile_pic",'alt'=>sprintf(__("%s profile"),$comment['User']['username']),'thumb'=>array('crop'=>true,'width'=>40,'height'=>40))),$comment['User']['profile_url'],array("escape"=>false));
					}
					echo "</td><td>";
					if(isset($comment['User']))
					{
						echo $html->link($comment['User']['display_name'],$comment['User']['profile_url'])." says";					
					}
					else
					{
						echo __("Admin");
					}
					echo "</td><td width='25%' style='text-align:right'>";
					echo $time->timeAgoInWords($comment['EventComment']['created'],array('shortString'=>true));
					echo "</td><td width='10%' style='text-align:right'>";
					echo $html->link(__('Delete'),array('plugin'=>'events','controller'=>'events','action'=>'delete_comment',$comment['EventComment']['id']));
					echo "</td><tr><td colspan=3>";				
					echo $comment['EventComment']['description']."<br/>";
					echo "</td>";					
				}
				echo "</table><br/>";
			} else {
				echo __("No comments posted yet");
			}
		?>
		<?php if(!empty($loggedInUser)):?>	
		<?php echo $form->create(array('type'=>'POST','action'=>'add_comment'));?>
		<?php echo $form->textarea('comment');?>
		<?php echo $form->hidden('eventId',array('value'=>$event['Event']['id']));?>
		<p align='right'>
		<?php
		echo $form->end(__('Add Comment'),array('div'=>array('class'=>'alignRight')));
		?>
		</p>
		<!-- ?php if(isset($tempData))debug('tempData '.$tempData);? -->
		<?php endif;?>
	</div>
	<?php echo $this->element('whosin', array('attendees' => $attendees,'interested'=>$interested,'eventIdForWhosIn'=>$event['Event']['id']));?>
	
		<div class="listing-view-map">
		<?php 
			//@GEOMAP INTERSECTION.
			if(checkSessionKey('geo_code'))
				echo $this->element("event_view_map",array('showStreetView'=>true,'event'=>$event));?>
	</div>
<script>
function doIt(){
	eventId = <?php echo $event['Event']['id'];?>;
	comment = document.getElementById('EventCommentEventComments').value;
	var url = "<?php echo $html->url(array('action'=>'add_comment'))?>";		
	url += '/eventId:'+eventId+'/comment:'+comment;
	return url;
}
</script>
